package com.hwhhhh.mygrad;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.hwhhhh.mygrad.dto.UserDTO;
import com.hwhhhh.mygrad.fragment.HintDialogFragment;
import com.hwhhhh.mygrad.fragment.UserInfoFragment;
import com.hwhhhh.mygrad.utils.StringUtils;
import com.hwhhhh.mygrad.view.IconfontView;
import com.hwhhhh.mygrad.view.RoundImageView;

public class UserInfoActivity extends BaseActivity implements View.OnClickListener{
    private static final int REQUEST_CODE_PHOTO = 101;

    private IconfontView icBack;

    @Override
    protected void initView() {
        icBack = findViewById(R.id.ic_back);
    }

    @Override
    protected int initLayout() {
        return R.layout.activity_user_info;
    }

    @Override
    protected void initData() {
        icBack.setOnClickListener(this);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.user_info_container, new UserInfoFragment(), UserInfoFragment.class.getSimpleName())
                .commit();
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.ic_back) {
            finish();
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_PHOTO) {
            if (data == null) return;
            Uri uri = data.getData();
            showToast("相册" + uri);
        }
    }

    public void enterOtherFragment(Fragment target) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        if (!target.isAdded()) {
            transaction.replace(R.id.user_info_container, target)
                    .addToBackStack(null)
                    .commit();
        }
    }

}